<template>
<h1>循环指令</h1>
<ul>
  <li v-for="uname in arr">{{uname}}</li>
</ul>
<ol>
  <li v-for="item in 5">{{item}}</li>
</ol>
  <table border="1" style="border-collapse: collapse">
    <caption>商品列表</caption>
    <tr>
      <th>序号</th>
      <th>商品标题</th>
      <th>商品价格</th>
      <th>商品数量</th>
    </tr>
    <tr v-for="(p,index) in productArr">
      <td>{{index+1}}</td>
      <td>{{p.title}}</td>
      <td>{{p.price}}</td>
      <td>{{p.num}}</td>
      <td><button @click="del(index)">删除</button></td>
    </tr>
  </table>
</template>

<script setup>
import {ref} from 'vue';
const arr = ref(["张三","李四","王五","赵六","钱七"]);
const productArr = ref([
  {title:'小米手机',price:5000,num:800},
  {title:'华为手机',price:5000,num:800},
  {title:'三星手机',price:5000,num:800},
  {title:'苹果手机',price:5000,num:800},
]);
const del = (index)=>{
    if(confirm('您是否确认删除词条数据?')){
      productArr.value.splice(index,1);
    }
};
</script>


<style scoped>
ul,ol{
  list-style: none;
}
</style>